<?php

class partner_block
{
	var $image = '';
	
	function partner_block($id = 0)
	{
		global $db;
		if($id == 0)
		{
			$q = 'SELECT * FROM ' . PARTNERS_TABLE . ' WHERE p_enabled = 1 ORDER BY RAND() LIMIT 1';
		}
		else
		{
			$q = 'SELECT * FROM ' . PARTNERS_TABLE . ' WHERE p_id = ' . $id;
		}
		
		$result = $db->sql_query($q);
		if($row = $db->sql_fetchrow($result)) 
		{
			$message = '<p width=&quot;300&quot; class=&quot;tableInfo&quot;><b>' . $row['p_title'] . '</b><br>';
			$message .= '<a href=&quot;' . $row['p_web'] . '&quot;>'. $row['p_web'] . '</a><br>';
			$message .= formatJSOutput($row['p_description']) . '</p>';
			$this->image = '<a href="' . $row['p_web'] . '" onmouseover="Tip(\'' . $message . 
						'\', BGCOLOR, \'#FFFFFF\', BORDERCOLOR, \'#000000\', STICKY, true, FADEIN, 500, FADEOUT, 500, WIDTH, 300)"'. 
						' onmouseout="UnTip()"><img src="' . $row['p_image'] . '"/></a>';
		}
	}


	function render()
	{
		global $skin_dir;
		
		$image = $this->image;
		include $skin_dir . 'tpl/partnerBlock.tpl';
		
	}
}

?>